package it.polimi.digitalstate.manager;

import it.polimi.digitalstate.dto.CitizenDTO;
import it.polimi.digitalstate.dto.UserDTO;
import it.polimi.digitalstate.entities.User;
import it.polimi.digitalstate.persist.SuperEntityManager;
import it.polimi.digitalstate.persist.SuperEntityManagerException;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;



/**
 * Session Bean implementation class AccountManager
 */
@LocalBean
@Stateless
public class AccountManager implements AccountManagerLocal {

    @PersistenceContext
	private EntityManager em;
    
    public AccountManager() {
        // TODO Auto-generated constructor stub
    }

	@Override
	public void createUser(UserDTO userdto) {
		em.persist(new User(userdto));	
	}

	@Override
	public void registerUser(UserDTO userdto, CitizenDTO citizen) throws SuperEntityManagerException {
		SuperEntityManager sem = new SuperEntityManager();
		sem.persist(em, userdto, citizen);
		
	}



}
